<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib  uri="/struts-tags"  prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>添加流程节点</title>
		<link href="css/table.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/openwindow.js"></script>
		<script type="text/javascript" src="js/node.js"></script>
		<script type="text/javascript" src="js/select.js"></script>
		<script type="text/javascript">
		function savenode(){
		var title=$("#name").val();
		var content=$("#content").val();
		var value=$("#nodestatus").val();
		if(title==''||title=='null'){
			alert('请添加节点名称');
			return;
		}
		var actor="";
		var input=$("input[name='node.actorType']");
		for(var i=0;i<input.length;i++){
			if(input[i].checked){
			actor=$(".textAll").eq(i).val();
			}
		}
		if(actor==""||actor=='null'){
			alert('请添加参与者');
			return;
		}
		$("#actors").val(actor);
		var obj = document.getElementById("obj2");
	   var array = getSelectArray(obj);
		  setformValue(array);
		$.post("saveFlowNodeForm.action",$("form").serialize(),function(data){
					if(data=='success'){
						alert("添加成功");
						window.close();
						window.opener.location.href="flowNodeManager.action?flowId="+${flowId};
					}else{
						if(data=="false"){alert("只能有一个开始节点");return;}
						alert("添加失败！");
					}
				});
	}
	
	
function func1(){
	var from = document.getElementById("obj1");
	var to = document.getElementById("obj2");
	moveTo(from,to);
	}
	function func2(){
	var from = document.getElementById("obj2");
	var to = document.getElementById("obj1");
	moveTo(from,to);
	}
	function func3(){
	var from = document.getElementById("obj1");
	var to = document.getElementById("obj2");
	moveAll(from,to);
	}
	function func4(){
	var from = document.getElementById("obj2");
	var to = document.getElementById("obj1");
	moveAll(from,to);
	}


function setformValue(value){
  var arr = eval(value);
  var names = "";
  var ids = "";
  for(i=0;i<arr.length;i++){
    ids =  ids + "," + arr[i].value;
    names = names + "," + arr[i].name;
  }
  if(names.length>0){
    names = names.substring(1);
    ids =  ids.substring(1);
  }
  document.getElementById("propertyid").value=ids;
}

</script>
	</head>
	<body>
		<table align="center" border="0" cellpadding="0" cellspacing="0"
			width="98%">
			<tbody>
				<tr>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
					<td style="background: url('image/wsoa_window_002.gif');">
						<table border="0" cellpadding="0" cellspacing="0">
							<tbody>
								<tr>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"
										width="10">
										<img src="image/center_19.gif">
									</td>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"></td>
									<td></td>
								</tr>
							</tbody>
						</table>
					</td>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
				</tr>
				<tr>
					<td style="background: url('image/wsoa_window_010.gif');" width="1">
						&nbsp;
					</td>
					<td>

						<form name="saveflownodeForm" id="saveflownode" method="post"
							action="">
							<input id="flowid" type="hidden" value="${flowId}"
								name="node.flowId">
							<input type="hidden" id="propertyid" name="propertyid">
							<input type="hidden" id="actors" name="users">
							<span class="font12"> </span>
							<table style="width: 99%;" align="center">
								<tbody>
									<tr>
										<td>
											<table style="width: 100%;" class="table5 bgcolor5"
												align="center">
												<tbody>
													<tr>
														<td align="right"  class="table5">
															节点名称：
														</td>
														<td class="table5">
															<input id="name" name="node.name" type="text"
																width="60%" height="15px" maxlength="20" />
														</td>
													</tr>
													<tr>
														<td align="right" class="table5">
															活动类型：
														</td>
														<td class="table5">
														<s:select id="nodestatus" cssStyle="width:30%" list="#{'0':'开始节点','1':'任务节点'}" name="node.status" value="node.status" theme="simple"></s:select>
														</td>
													</tr>
													<tr>
														<td align="right" class="table5">
															活动描述：
														</td>
														<td class="table5" height="100px">
															<textarea id="content" onkeyup="textLength(this,200)" style="width: 90%; height: 80px"
																name="node.content"></textarea>
														</td>
													</tr>
													<tr id="nodeActor">
														<td align="right" class="table5">
															参与者：
														</td>
														<td class="table5">
															<input type="radio"
																onclick="selectNodeActor('transactor')"
																id="transactorType" name="node.actorType" value="1" />
															指定办理人
															<br />
															<div id="transactor" style="display: none;">
																<textarea  cols="20"
																	readonly="readonly"   id="snames"
																	style="height: 30px; width: 350px">${names}</textarea>
																<input type="hidden"   class="textAll"  id="sids" 
																	value="${users}">
																<input type="button" class="sscc" onclick="selectUser('s')">
															</div>
															<input type="radio" id="candidateType"
																onclick="selectNodeActor('candidate')"
																name="node.actorType" value="2" />
															从候选人员中指定
															<br />
															<div id="candidate"  style="display: none;">
																<textarea  cols="20"   
																	readonly="readonly"    id="cnames" 
																	style="height: 30px; width: 350px">${names}</textarea>
																<input type="hidden" id="cids"  class="textAll"
																	value="${users}">
																<input type="button" class="sscc" onclick="selectUser('c')">
															</div>
															<input type="radio" id="orgsType" name="node.actorType"
																onclick="selectNodeActor('orgs')" value="3" />
															从部门中指定
															<br />
															<div id="orgs" style="display: none;">
																<textarea  cols="20"  
																	readonly="readonly" id="onames"
																	style="height: 30px; width: 350px">${names}</textarea>
																<input type="hidden" id="oids" class="textAll"
																	value="${users}">
																<input type="button" class="sscc" onclick="selectorg('o')">
															</div>
															<input type="radio" name="node.actorType"
																onclick="selectNodeActor('all')" value="4" />
															流程启动人
															<br />
															<input type="radio" name="node.actorType"
																onclick="selectNodeActor('allmore')" value="5" />
															由上一节点参与者从所有人员中指定
															<br />
														</td>
													</tr>
													<tr>
														<td align="right">
															发起时不填的字段
														</td>
														<td>
															<div style="float: left;">
																<select name="possible" id="obj1" size="4" MULTIPLE
																	style="width: 130px; height: 260px;">

																	<c:forEach items="${formProportyList}" var="property">
																		<option value="${property.id}">
																			${property.proportyName}
																		</option>
																	</c:forEach>

																</select>
															</div>
															<div style="float: left; margin-top: 100px;">
																<input type="button" onclick="func1()" class="button_02"
																	value=">">
																<br>
																<br>
																<input type="button" onclick="func3()" class="button_02"
																	value=">>">
																<br>
																<br>
																<input type="button" class="button_02" onclick="func2()" value="<"> <br><br>
                  <input type="button" width="25px" onclick="func4()" class="button_02" value="<<">
                  <br /><br />
				</div>
                
                  <select name="chosen" id="obj2" size="4" MULTIPLE style="width: 130px;height:260px">
                     
                  </select>
                </td>
              </tr>  
													
												</tbody>
											</table>
										</td>
									</tr>

									<tr>
										<td>
											<table style="width: 100%;" class="table5 bgcolor5"
												align="center">
												<tbody>
												</tbody>
											</table>
										</td>
									</tr>
								</tbody>
							</table>
							<table style="width: 99%;" align="center">
								<tbody>
									<tr>
										<td align="center">
											<span id="errorId"></span>
										</td>
									</tr>
									<tr>
										<td align="center">
											<input accesskey="t" value="提交"
												style="background: url('image/button_02.gif');"
												onclick="savenode();" class="button_02" type="button">
											<input class="button_02" value="取消" accesskey="c"
												style="background: url('image/button_02.gif');"
												onclick="window.close();" type="button">
										</td>
									</tr>
								</tbody>
							</table>
						</form>
					</td>
					<td style="background: url('image/wsoa_window_006.gif');" width="1">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td height="1" width="1">
						<img src="image/wsoa_window_009.gif" height="16" width="14">
					</td>
					<td style="background: url('image/wsoa_window_008.gif');"
						height="1"></td>
					<td height="1" width="1">
						<img src="image/wsoa_window_007.gif" height="16" width="12">
					</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>